package com.adee.nowcoder.huawei;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.LinkedList;

public class T048_HJ048 {
    public static void main(String[] args) throws ScriptException {
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(3,10);
        System.out.println(list);
        ScriptEngineManager em = new ScriptEngineManager();
        ScriptEngine engine = em.getEngineByName("JavaScript");
        String s = "3+2*{1+2*[-4/(8-6)+7]}";
        s = s.replaceAll("\\{", "\\(")
                .replaceAll("\\[", "\\(")
                .replaceAll("\\}", "\\)")
                .replaceAll("\\]", "\\)");
        System.out.println(engine.eval(s));
    }
}
